from itsdangerous import TimedJSONWebSignatureSerializer as Serializer

from mall import settings


def generate_save_token(vaule1,vaule2):
    serializer = Serializer(settings.SECRET_KEY,expires_in=3600)

    data = {
        'id':vaule1,
        'email':vaule2

            }

    token = serializer.dumps(data)

    return 'http://www.meiduo.site:8080/success_verify_email.html?token=%s'%token.decode()


def generate_check_token(data):

    serializer = Serializer(settings.SECRET_KEY,expires_in=3600)

    try:
        data = serializer.loads(data)

    except Exception:
        return None

    return data